﻿<navigation:Page
    xmlns:my1="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Ria"
    xmlns:my="clr-namespace:Web.Services"
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:my2="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
    xmlns:System_Windows_Data="clr-namespace:System.Windows.Data;assembly=System.Windows.Controls.Ria"
    x:Class="TheOliver.DigitalSignage.Admin.Views.Slots"
    d:DesignWidth="640"
    d:DesignHeight="480"
    Title="Slots Page">
    <my2:BusyIndicator
        IsBusy="{Binding DomainContext.IsLoading, ElementName=eventDomainDataSource}"
        BusyContent="Loading Event Data ...">
        <my2:BusyIndicator
            IsBusy="{Binding DomainContext.IsLoading, ElementName=roomDomainDataSource}"
            BusyContent="Loading Room Data ...">
            <my2:BusyIndicator
                IsBusy="{Binding DomainContext.IsLoading, ElementName=sessionDomainDataSource}"
                BusyContent="Loading Session Data ...">
                <my2:BusyIndicator
                    IsBusy="{Binding DomainContext.IsLoading, ElementName=speakerDomainDataSource}"
                    BusyContent="Loading Speaker Data ...">
                    <my2:BusyIndicator
                        IsBusy="{Binding DomainContext.IsLoading, ElementName=slotDomainDataSource}"
                        BusyContent="Loading Slot Data ...">

                        <Grid
                            x:Name="LayoutRoot" Margin="0">
                            <Grid.RowDefinitions>
                                <RowDefinition
                                    Height="28" />
                                <RowDefinition />
                                <RowDefinition
                                    Height="35" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <StackPanel
                                x:Name="_filterpanel"
                                Margin="8,4,0,4"
                                Orientation="Horizontal"
                                VerticalAlignment="Center"
                                Grid.ColumnSpan="1">
                                <TextBlock
                                    x:Name="_eventLabel"
                                    TextWrapping="Wrap"
                                    Text="Event"
                                    VerticalAlignment="Center"
                                    Margin="0,0,4,0" />
                                <ComboBox
                                    x:Name="_eventCombo"
                                    HorizontalAlignment="Left"
                                    Width="115"
                                    ItemsSource="{Binding Data, ElementName=eventDomainDataSource}"
                                    DisplayMemberPath="Name"
                                    SelectionChanged="_eventCombo_SelectionChanged" />
                                <Button
                                    x:Name="_clearEvent"
                                    Content="X"
                                    Margin="2,0,4,0" />
                                <TextBlock
                                    x:Name="_roomLabel"
                                    TextWrapping="Wrap"
                                    Text="Room"
                                    VerticalAlignment="Center"
                                    Margin="8,0,4,0" />
                                <ComboBox
                                    x:Name="_roomCombo"
                                    Width="120" DisplayMemberPath="Name" ItemsSource="{Binding ElementName=roomDomainDataSource, Path=DomainContext.Rooms}" SelectionChanged="_roomCombo_SelectionChanged" />
                                <Button
                                    x:Name="_clearRoom"
                                    Content="X"
                                    Margin="2,0,4,0" />
                                <TextBlock
                                    x:Name="_dayLabel"
                                    TextWrapping="Wrap"
                                    Text="Day"
                                    VerticalAlignment="Center"
                                    Margin="8,0,4,0" />
                                <ComboBox
                                    x:Name="_dayCombo"
                                    Width="120" />
                                <Button
                                    x:Name="_clearDay"
                                    Content="X"
                                    Margin="2,0,4,0" />
                            </StackPanel>
                            <data:DataGrid
                                AutoGenerateColumns="False"
                                ItemsSource="{Binding ElementName=slotDomainDataSource, Path=DomainContext.Slots, Mode=TwoWay}"
                                Margin="8,8,8,30"
                                x:Name="slotDataGrid"
                                RowDetailsVisibilityMode="VisibleWhenSelected"
                                Grid.ColumnSpan="1"
                                Grid.Row="1" MinColumnWidth="10">
                                <data:DataGrid.Columns>
                                    <data:DataGridTemplateColumn
                                        x:Name="dateColumn"
                                        Header="Date"
                                        Width="100">
                                        <data:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <controls:DatePicker
                                                    SelectedDate="{Binding Date, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                                            </DataTemplate>
                                        </data:DataGridTemplateColumn.CellTemplate>
                                    </data:DataGridTemplateColumn>

                                    <data:DataGridTemplateColumn
                                        x:Name="timeColumn"
                                        Header="Time"
                                        Width="70">
                                        <data:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox
                                                    Text="{Binding Time, Mode=TwoWay}" />
                                            </DataTemplate>
                                        </data:DataGridTemplateColumn.CellTemplate>
                                    </data:DataGridTemplateColumn>

                                    <!--
                                <data:DataGridTextColumn
                                    x:Name="timeColumn"
                                    Binding="{Binding Time}"
                                    Header="Time"
                                    Width="100" />
                                    -->

                                    <data:DataGridTemplateColumn
                                        x:Name="roomIdColumn"
                                        Header="Room"
                                        Width="150">
                                        <data:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <ComboBox
                                                    Loaded="roomId_Loaded"
                                                    SelectionChanged="roomId_SelectionChanged"
                                                    DisplayMemberPath="Name" />
                                            </DataTemplate>
                                        </data:DataGridTemplateColumn.CellTemplate>
                                    </data:DataGridTemplateColumn>
                                    <data:DataGridTemplateColumn
                                        x:Name="sessionIdColumn"
                                        Header="Session"
                                        Width="150">
                                        <data:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <ComboBox
                                                    Loaded="sessionId_Loaded"
                                                    SelectionChanged="sessionId_Changed"
                                                    DisplayMemberPath="ShortTitle" />
                                            </DataTemplate>
                                        </data:DataGridTemplateColumn.CellTemplate>
                                    </data:DataGridTemplateColumn>
                                    <data:DataGridTemplateColumn
                                        x:Name="speakerIdColumn"
                                        Header="Speaker"
                                        Width="150">
                                        <data:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <ComboBox
                                                    Loaded="speakerId_Loaded"
                                                    LayoutUpdated="speakerId_LayoutUpdated"
                                                    SelectionChanged="speakerId_Changed"
                                                    DisplayMemberPath="Lastname" />
                                            </DataTemplate>
                                        </data:DataGridTemplateColumn.CellTemplate>
                                    </data:DataGridTemplateColumn>
                                    
                                    <data:DataGridTemplateColumn
                                        x:Name="spId"
                                        Header="SpeakerId"
                                        Width="70">
                                        <data:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock
                                                    Text="{Binding SpeakerId}" />
                                            </DataTemplate>
                                        </data:DataGridTemplateColumn.CellTemplate>
                                    </data:DataGridTemplateColumn>
                                                                        
                                    <data:DataGridTemplateColumn
                                        x:Name="seId"
                                        Header="SessionId"
                                        Width="70">
                                        <data:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate >
                                                <TextBlock
                                                    Text="{Binding SessionId}" />
                                            </DataTemplate>
                                        </data:DataGridTemplateColumn.CellTemplate>
                                    </data:DataGridTemplateColumn>

                                    <data:DataGridTemplateColumn
                                        x:Name="rId"
                                        Header="RoomId"
                                        Width="70">
                                        <data:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock
                                                    Text="{Binding RoomId}" />
                                            </DataTemplate>
                                        </data:DataGridTemplateColumn.CellTemplate>
                                    </data:DataGridTemplateColumn>

                                </data:DataGrid.Columns>
                            </data:DataGrid>
                            <StackPanel
                                HorizontalAlignment="Left"
                                Margin="8,0,8,8"
                                x:Name="_addRemovePanel"
                                VerticalAlignment="Bottom"
                                Orientation="Horizontal"
                                Grid.Row="2">
                                <Button
                                    Content="Add"
                                    Height="23"
                                    x:Name="_add"
                                    Width="75"
                                    Click="_add_Click" />
                                <Button
                                    Content="Remove"
                                    Height="23"
                                    x:Name="_remove"
                                    Width="75"
                                    Click="_remove_Click" />
                            </StackPanel>
                            <StackPanel
                                HorizontalAlignment="Right"
                                x:Name="_changesPanel"
                                Orientation="Horizontal"
                                Margin="0,0,8,8"
                                Grid.Row="2"
                                VerticalAlignment="Bottom" d:LayoutOverrides="HorizontalAlignment">
                                <Button
                                    Content="Save changes"
                                    IsEnabled="{Binding DomainContext.HasChanges, ElementName=slotDomainDataSource}"
                                    x:Name="_save"
                                    Click="_save_Click" />

                                <Button
                                    Content="Reject changes"
                                    IsEnabled="{Binding DomainContext.HasChanges, ElementName=slotDomainDataSource}"
                                    x:Name="_reject"
                                    Click="_reject_Click" />
                            </StackPanel>
                            <riaControls:DomainDataSource
                                AutoLoad="False"
                                Height="0"
                                LoadedData="slotDomainDataSource_LoadedData"
                                x:Name="slotDomainDataSource"
                                QueryName="GetSlotsByRoom"
                                Width="0"
                                Margin="480,12,160,144"
                                Grid.Row="2">
                                <riaControls:DomainDataSource.GroupDescriptors>
                                    <System_Windows_Data:GroupDescriptor>
                                        <System_Windows_Data:Parameter
                                            ParameterName="{x:Null}"
                                            Value="Date" />
                                        
                                    </System_Windows_Data:GroupDescriptor>
                                </riaControls:DomainDataSource.GroupDescriptors>

                                <riaControls:DomainDataSource.DomainContext>
                                    <my:DigitalSignageDomainContext />
                                </riaControls:DomainDataSource.DomainContext>

                            </riaControls:DomainDataSource>
                            <riaControls:DomainDataSource
                                AutoLoad="False"
                                Height="0"
                                LoadedData="roomDomainDataSource_LoadedData"
                                x:Name="roomDomainDataSource"
                                QueryName="GetRoomByEventQuery"
                                Width="0"
                                Margin="480,12,160,144"
                                Grid.Row="2">
                                <riaControls:DomainDataSource.DomainContext>
                                    <my:DigitalSignageDomainContext />
                                </riaControls:DomainDataSource.DomainContext>

                            </riaControls:DomainDataSource>
                            <riaControls:DomainDataSource
                                AutoLoad="False"
                                Height="0"
                                LoadedData="sessionDomainDataSource_LoadedData"
                                x:Name="sessionDomainDataSource"
                                QueryName="GetSessionQuery"
                                Width="0"
                                Margin="480,12,160,144"
                                Grid.Row="2">
                                <riaControls:DomainDataSource.DomainContext>
                                    <my:DigitalSignageDomainContext />
                                </riaControls:DomainDataSource.DomainContext>
                            </riaControls:DomainDataSource>
                            <riaControls:DomainDataSource
                                AutoLoad="False"
                                Height="0"
                                LoadedData="speakerDomainDataSource_LoadedData"
                                x:Name="speakerDomainDataSource"
                                QueryName="GetSpeakerQuery"
                                Width="0"
                                Margin="480,12,160,144"
                                Grid.Row="2">
                                <riaControls:DomainDataSource.DomainContext>
                                    <my:DigitalSignageDomainContext />
                                </riaControls:DomainDataSource.DomainContext>
                            </riaControls:DomainDataSource>
                            <riaControls:DomainDataSource
                                AutoLoad="True"
                                Height="0"
                                LoadedData="eventDomainDataSource_LoadedData"
                                x:Name="eventDomainDataSource"
                                QueryName="GetEventQuery"
                                Width="0" Margin="160,14,480,14">
                                <riaControls:DomainDataSource.DomainContext>
                                    <my:DigitalSignageDomainContext />
                                </riaControls:DomainDataSource.DomainContext>
                            </riaControls:DomainDataSource>
                            <data:DataPager Margin="8,0,8,6" Grid.Row="1" VerticalAlignment="Bottom" PageSize="10" DataContext="{Binding ElementName=slotDomainDataSource, Path=DomainContext.Slots, Mode=TwoWay}" Source="{Binding}" Name="_dataPager" />
                        </Grid>
                    </my2:BusyIndicator>
                </my2:BusyIndicator>
            </my2:BusyIndicator>
        </my2:BusyIndicator>
    </my2:BusyIndicator>
</navigation:Page>
